﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace Client
{
    public partial class ThietLap : Form
    {
        public int flag = 1;
        public ThietLap()
        {
            InitializeComponent();
        }
        CConfig config = new CConfig();
        private void btnclose_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
        {
            if (flag == 0)
                Application.Exit();
            this.Close();
        }

        private void ThietLap_Load(object sender, EventArgs e)
        {
        
                string[] ip = config.Ip.ToString().Split(new char[] { '.' }, StringSplitOptions.RemoveEmptyEntries);
                ip1.Value = decimal.Parse(ip[0]);
                ip2.Value = decimal.Parse(ip[1]);
                ip3.Value = decimal.Parse(ip[2]);
                ip4.Value = decimal.Parse(ip[3]);
                txtport.Value = config.Port;
                txtHNS.Text = config.Hostserver;

        }
        
        private void button1_Click(object sender, EventArgs e)
        {
            string ip = ip1.Value.ToString() + "." + ip2.Value.ToString() + "." + ip3.Value.ToString() + "." + ip4.Value.ToString();

            config.GhiFileConfig(ip,txtHNS.Text,int.Parse(txtport.Value.ToString()));
            if (flag == 0)
            {
                flag = 1;
            }
            this.Close();
        }

       
    }
}
